//
//  WelcomeController.swift
//  JGWB
//
//  Created by 付建国 on 2016/10/12.
//  Copyright © 2016年 sher. All rights reserved.
//

import UIKit
import SDWebImage

class WelcomeController: UIViewController {

    // MARK:- 属性
    
    @IBOutlet weak var iconViewBottomCons: NSLayoutConstraint!
    
    @IBOutlet weak var headImageV: UIImageView!
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let profileURLString = PersonViewModel.shareIntance.account?.avatar_large
        // ?? "" ：如果？？前面的可选类型有值，那么前面的可选类型直接解包并赋值，如果没有值，则使用后面默认的值
        let url = URL.init(string: profileURLString ?? "avatar_default_big")
        
        headImageV.sd_setImage(with: url, placeholderImage: UIImage.init(named: "avatar_default_big"))
        
        //执行动画
        //Damping:阻力系数，系数越大，弹动效果越不明显0~1
        //initialSpringVelocity:初始化速度
//        适配iOS7之前let snap = UISnapBehavior() snap.damping
        UIView.animate(withDuration: 1.5, delay: 0.0, usingSpringWithDamping: 0.7, initialSpringVelocity: 5.0, options: [], animations: {
            
            self.headImageV.layoutIfNeeded()
            //改变约束值
            self.iconViewBottomCons.constant = UIScreen.main.bounds.height - 250
            
            }) { (Bool) in
                
                UIApplication.shared.keyWindow?.rootViewController = UIStoryboard.init(name: "Main", bundle: nil).instantiateInitialViewController()
                
        }

    }
    


}
